<!DOCTYPE HTML>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
	<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
	<title>首页</title>
	<link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
	<link rel="stylesheet" type="text/css" href="../css/common.css" />
	<style>
		.box {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 5px 30px;
			background-color: #fff;
		}

		.box>div {
			display: flex;
			flex-direction: column;
			align-items: center;
			font-size: 12px;
			color: #666;
		}

		.box>div>img {
			width: 30px;
			height: 30px;
		}

		a:link,
		a:active {
			background: #FFFFFF !important;
		}

		.second_list li {
			margin: 0 !important;
		}

		.flex_ul {
			padding-bottom: 10px;
		}

		.flex_ul>li {
			padding: 0 15px !important;
		}

		.flex_ul>li>a {
			padding: 0 !important;
		}
	</style>
</head>

<body>
	<div class="mui-content">
		<ul class="flex_list">
			<li tapmode onclick="newOrder('')">
				<i class="mue-iocn new-icon"></i>
				<span>新建工单</span>
			</li>
			<li tapmode onclick="ckFun(1)">
				<i class="mue-iocn ck-icon"></i>
				<span>工单跟踪</span>
			</li>
			<li tapmode onclick="openTastWin('status_monitoing', '测点列表')">
				<i class="mue-iocn jk-icon"></i>
				<span>状态监控</span>
			</li>
			<li tapmode onclick="openStockWin()">
				<i class="mue-iocn wl-icon"></i>
				<span>物料查询</span>
			</li>
		</ul>
		<ul class="flex_list second_list">
			<li tapmode onclick="Scanner(1)">
				<!--<li onclick="showTooltc('OrderTool')">-->
				<i class="mue-iocn scode-icon"></i>
				<span>设备扫码</span>
			</li>
			<li tapmode onclick="Scanner(2)">
				<i class="mue-iocn scode-icon"></i>
				<span>物料扫码</span>
			</li>
			<li tapmode onclick="Scanner(3)">
				<i class="mue-iocn scode-icon"></i>
				<span>入库防错</span>
			</li>
		</ul>
		<ul class="flex_ul mui-table-view mui-grid-view mui-grid-9">
			<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3" onclick="goTableChart()" tapmode>
				<a href="#">
					<span class="mui-icon"><img src="../image/table.png" alt="" style="width:1.2rem"></span>
					<div class="mui-media-body" style="font-size:0.6rem">工单管理</div>
				</a>
			</li>
			<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3" onclick="goTableChart2()" tapmode>
				<a href="#">
					<span class="mui-icon"><img src="../image/table.png" alt="" style="width:1.2rem"></span>
					<div class="mui-media-body" style="font-size:0.6rem">备件管理</div>
				</a>
			</li>
			<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3" onclick="goTableChart3()" tapmode>
				<a href="#">
					<span class="mui-icon"><img src="../image/table.png" alt="" style="width:1.2rem"></span>
					<div class="mui-media-body" style="font-size:0.6rem">报表管理</div>
				</a>
			</li>
			<li class="mui-table-view-cell mui-media mui-col-xs-3 mui-col-sm-3" onclick="goTableChart4()" tapmode>
				<a href="#">
					<span class="mui-icon"><img src="../image/table.png" alt="" style="width:1.2rem"></span>
					<div class="mui-media-body" style="font-size:0.6rem">资料管理</div>
				</a>
			</li>
		</ul>

		<!--待办-->
		<h5 class="deal_title flex padding_r_1rem"><span>工单待办列表<span id="workTodoCount" style="margin-left:0.5rem; font-weight: 800;"></span></span><span class="right_arrow_icon" onclick="openTastWin('work_order_manage','待办工单管理',{isTodo:1})">全部</span></h5>
		<ul class="mui-table-view deal_list" id="orderList">
			<script type="text/template" id="tmpList2">
				{{each datas as item i}}
				<li class="mui-table-view-cell" tapmode onclick="openOrderDetailWin('{{item.workorderid}}', '{{item.wonum}}')">
					<div class="mui-table">
						{{if item.isTimeOut == '1'}}
						<div class="mui-table-cell mui-col-xs-9">
							<h4 class="mui-ellipsis"><img src="../image/warning.png" style="width:0.8rem;display:inline-block;margin-right:0.2rem;"/>{{item.wonum}}</h4>
							<p class="mui-h6 mui-ellipsis">{{item.description}}</p>
						</div>
						{{else}}
						<div class="mui-table-cell mui-col-xs-9">
							<h4 class="mui-ellipsis">{{item.wonum}}</h4>
							<p class="mui-h6 mui-ellipsis">{{item.description}}</p>
						</div>
						{{/if}}
						<div class="mui-table-cell mui-col-xs-3 mui-text-right">
							<span class="mui-h5">{{item.status}}</span>
						</div>
					</div>
				</li>
				{{/each}}
			</script>
			<div class="mui-hidden" id="orderdbTip">
				<p class="no_list">
					暂无待办
				</p>
			</div>
		</ul>
		<h5 class="deal_title flex padding_r_1rem"><span>物料待办列表<span id="wuliaoTodoCount" style="margin-left:0.5rem; font-weight:800;"></span></span><span class="right_arrow_icon" onclick="openTastWin('stock_list_wait','待办物料列表',{isTodo:1})">全部</span></h5>
		<!--待办-->
		<ul class="mui-table-view deal_list" id="todoCnt">
			<script type="text/template" id="tmpList1">
				{{each datas as item i}}
				<li class="mui-table-view-cell" tapmode onclick="openMaterialDetailWin('{{item.matusetransid}}','{{item.inventoryid}}','{{item.status}}','{{item.invbalancesid}}')">
					<div class="mui-table">
						{{if item.isTimeOut == '1'}}
						<div class="mui-table-cell mui-col-xs-9">
							<h4><img src="../image/warning.png" style="width:0.8rem;display:inline-block;margin-right:0.2rem;"/>{{item.itemnum}}<span style="font-size:0.6rem;margin-left:0.6rem;">{{item.itemDesc}}</span></h4>
							<p class="mui-h6 mui-ellipsis">{{item.description}}</p>
						</div>
						{{else}}
						<div class="mui-table-cell mui-col-xs-9">
							<h4 class="mui-ellipsis">{{item.itemnum}}<span style="font-size:0.6rem;margin-left:0.6rem;">{{item.itemDesc}}</span></h4>
							<p class="mui-h6 mui-ellipsis">{{item.description}}</p>
						</div>
						{{/if}}
						<div class="mui-table-cell mui-col-xs-3 mui-text-right">
							{{if item.status==1}}
							<span class="mui-h5">出库审批</span> {{else if item.status == 2}}
							<span class="mui-h5">修改物料</span> {{/if}}
						</div>
					</div>
				</li>
				{{/each}}
			</script>
			<div class="mui-hidden" id="stockdbTip">
				<p class="no_list">
					暂无待办
				</p>
			</div>
		</ul>
		<!--设备扫码（工单）-->
		<div class="tc_showTool mui-hidden" id="OrderTool">
			<ul class="flex_list second_list">
				<li tapmode onclick="newOrder(Scannervalue)">
					<i class="mue-iocn unerror-icon"></i>
					<span>新建工单</span>
				</li>
				<li tapmode onclick="openTastWin('work_order_manage','工单管理',{home: 'home',type: 'pm',orderType: 'P01,P02',cRegion: Scannervalue})">
					<i class="mue-iocn unerror-icon"></i>
					<span>PM工单</span>
				</li>
				<!-- onclick="openSaveWin('tmp_order','巡点检项')"-->
				<li tapmode onclick="openTastWin('work_order_manage','工单管理',{
					home: 'home',
					type: 'TPM',
					orderType: 'T04',
					cRegion: Scannervalue
					})">
					<i class="mue-iocn unerror-icon"></i>
					<span>TPM工单</span>
				</li>
				<li tapmode onclick="openTastWin('work_order_manage','工单管理',{
					home: 'home',
					type: 'TIS',
					orderType: 'T03',
					cRegion: Scannervalue
					})">
					<i class="mue-iocn unerror-icon"></i>
					<span>TIS工单</span>
				</li>
				<li tapmode onclick="openNewWin('status_monitoing', '测点列表',{
					cRegion: Scannervalue
					})">
					<i class="mue-iocn unerror-icon"></i>
					<span>状态监控</span>
				</li>
			</ul>
			<div class="close_btn" onclick="cancelTooltc('OrderTool')">
				取消
			</div>
		</div>
		<!--物料扫码-->
		<div class="tc_showTool mui-hidden" id="StockTool">
			<ul class="flex_list second_list">
				<li tapmode onclick="openstockDetailWin(StockScannervalue,Scannervalue)">
					<i class="mue-iocn unerror-icon"></i>
					<span>备件详情</span>
				</li>
				<li tapmode onclick="openTastWin('stock_out_record','入库记录',{
					recordType: 1,
					itemnum: StockScannervalue
					})">
					<i class="mue-iocn unerror-icon"></i>
					<span>入库记录</span>
				</li>
				<li tapmode onclick="openSaveWin('stock_out','物料出库',{
					binnum:Scannervalue,
					itemnum:StockScannervalue,
					address:Scannervalue
					})">
					<i class="mue-iocn unerror-icon"></i>
					<span>出库</span>
				</li>
				<li tapmode onclick="openTastWin('stock_out_record','出库记录',{
					recordType: 2,
					itemnum: StockScannervalue
					})">
					<i class="mue-iocn unerror-icon"></i>
					<span>出库记录</span>
				</li>
				<li tapmode onclick="openSaveWin('stock_out','物料出库',{
					binnum:Scannervalue,
					address:Scannervalue,
					itemnum:StockScannervalue
					})">
					<i class="mue-iocn unerror-icon"></i>
					<span>白条登记</span>
				</li>
			</ul>
			<div class="close_btn" onclick="cancelTooltc('StockTool')">
				取消
			</div>
		</div>
		<!--入库防错-->
		<div class="tc_showTool mui-hidden" id="rkTool">
			<div class="inStockMTInfo">
				<span id="scanerVal"></span>
			</div>
			<div class="close_btn" onclick="cancelTooltc('rkTool')">
				关闭
			</div>
		</div>
	</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script src="../script/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/common.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/template.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	var FNScanner;
	var ajpush = null;
	var ckFun = function(id) {
		api.setTabBarAttr({
			index: id
		});
	}
	var newOrder = function(location) {
		openSaveWin('new_work_order', '新建工单', {
			locations: location
		})
	}
	apiready = function() {
		$api.rmStorage('workstatus');
		FNScanner = api.require('FNScanner');
		onLoadData();
		api.addEventListener({
			name: 'refersh'
		}, function(ret, err) {
			if (ret.value.isrefersh == 'yes') {
				onLoadData();
			}
		});
		Refresh(function() {
			onLoadData();
		});
		//监听应用回到前台
		api.addEventListener({
			name: 'resume'
		}, function(ret, err) {
			FNScanner.onResume();
		});
		//监听应用回到后台
		api.addEventListener({
			name: 'pause'
		}, function(ret, err) {
			FNScanner.onPause();
		});
	}

	function onLoadData() {
		queryMaterialsTodoList();
		queryOrderTodoList();
		getWorkTodoCount();
		getWuliaoTodoCount();
		getMessgeNum();
	}

	function queryMaterialsTodoList() {
		ajaxrd("queryMaterialsTodoList", {
			pageNo: 1,
			pageSize: 5
		}, function(ret, err) {
			api.refreshHeaderLoadDone();
			if (ret.list.length == 0) {
				$api.removeCls($api.byId('stockdbTip'), 'mui-hidden');
				AddData('tmpList1', 'todoCnt', ret.list);
			} else {
				$api.addCls($api.byId('stockdbTip'), 'mui-hidden');
				AddData('tmpList1', 'todoCnt', ret.list);
			}
		})
	}

	function queryOrderTodoList() {
		ajaxrd("queryOrderTodoList", {
			pageNo: 1,
			pageSize: 5
		}, function(ret, err) {
			api.refreshHeaderLoadDone();
			if (ret.list.length == 0) {
				$api.removeCls($api.byId('orderdbTip'), 'mui-hidden');
				AddData('tmpList2', 'orderList', ret.list);
			} else {
				$api.addCls($api.byId('orderdbTip'), 'mui-hidden');
				AddData('tmpList2', 'orderList', ret.list);
			}
		})
	}

	// 工单详情
	function openOrderDetailWin(workorderid, wonum) {
		openWin('work_order_manage_detail', '工单详细信息', {
			background: '#6098de',
			color: '#fff',
			rightButtons: [{
				iconPath: "widget://image/operate-icon.png"
			}]
		}, {
			workorderid: workorderid,
			wonum: wonum
		})
	}

	// 物料详情
	function openstockDetailWin(itemid, binnum) {
		openWin('stock_detail', '物料详情', {
			background: '#6098de',
			color: '#fff',
			rightButtons: [{
				iconPath: "widget://image/operate-icon.png"
			}]
		}, {
			itemid: itemid,
			binnum: binnum
		})
	}

	// 物料出库
	function openMaterialDetailWin(matusetransid, inventoryid, status, invbalancesid) {
		if (status == '1') {
			openTastWin('stock_out_detail', '出库审批', {
				matusetransid: matusetransid,
				inventoryid: inventoryid,
				invbalancesid: invbalancesid
			})
		} else {
			openSaveWin('stock_out_edit', '编辑物料出库', {
				matusetransid: matusetransid,
				invbalancesid: invbalancesid
			})
		}
	}
	function onGoTPM() {
		openWin('TPM_page','TPM',{
				background: '#6098de',
				color: '#fff',
				rightButtons:[{
					// iconPath:"widget://image/save-icon.png"
				}]
		})
	}
	function onGoPDM() {
		openWin('PDM_page','PDM',{
				background: '#6098de',
				color: '#fff',
				rightButtons:[{
					// iconPath:"widget://image/save-icon.png"
				}]
		})
	}

	function openStockWin() {
		openWin('stock_list', '库存清单', {
			background: '#6098de',
			color: '#fff',
			rightButtons: [{
				iconPath: "widget://image/sys-icon.png"
			}]
		}, {
			location: ''
		})
	}

	function getWorkTodoCount() {
		ajaxrd("queryWorkTodoCnt", {}, function(ret, err) {
			if (ret && parseInt(ret.cnt) > 0) {
				$api.text($api.byId("workTodoCount"), "(总待办数：" + ret.cnt + ")");
			}
		});
	}

	function getWuliaoTodoCount() {
		ajaxrd("queryItemTodoCnt", {}, function(ret, err) {
			if (ret && parseInt(ret.cnt) > 0) {
				$api.text($api.byId("wuliaoTodoCount"), "(总待办数：" + ret.cnt + ")");
			}
		});
	}

	function getMessgeNum() {
		ajaxrd("queryTodoCnt", {}, function(ret, err) {
			if (ret && parseInt(ret.cnt) > 0) {
				api.toast({
					msg: "温馨提示，您共有 " + ret.cnt + "待办待处理！",
					duration: 3000,
					location: 'middle'
				});
			}
		})
	}

	function goTableChart() {
		api.actionSheet({
    cancelTitle: '取消',
    buttons: ['未完成工单', '工单排序']
		},function(ret,err){
			if (ret.buttonIndex == 1) {
				openWin('order_chart1', '未完成工单', {
					background: '#6098de',
					color: '#fff'
				})
			} else if (ret.buttonIndex == 2) {
				openWin('order_chart2', '工单排序', {
					background: '#6098de',
					color: '#fff'
				})
			}
		});
	}
	function goTableChart2() {
		api.actionSheet({
		cancelTitle: '取消',
		buttons: ['发放表']
		},function(ret,err){
			if (ret.buttonIndex == 1) {
				openWin('order_chart3', '发放表', {
					background: '#6098de',
					color: '#fff'
				})
			}
		});
	}
	function goTableChart3() {
		api.actionSheet({
		cancelTitle: '取消',
		buttons: ['设备故障频度', 'MTTR报表', 'TPM报表', 'PDM报表']
		},function(ret,err){
			if (ret.buttonIndex == 1) {
				openWin('order_chart4', '设备故障频度', {
					background: '#6098de',
					color: '#fff'
				})
			} else if (ret.buttonIndex == 2) {
				openWin('order_chart5', 'MTTR报表', {
					background: '#6098de',
					color: '#fff'
				})
			}else if (ret.buttonIndex == 3) {
				onGoTPM()
			}else if (ret.buttonIndex == 4) {
				onGoPDM()
			}
		});
	}
	function goTableChart4() {
		api.actionSheet({
			cancelTitle: '取消',
			buttons: ['技术资料']
		},function(ret,err){
			if (ret.buttonIndex == 1) {
				openWin('key_technologyList', '技术资料', {
		        background: '#6098de',
		        color: '#fff'
		    })
			}
		})
	}
</script>

</html>
